﻿<%@ Page Title="" Language="C#" MasterPageFile="../Shared/Manager.Master" Inherits="System.Web.Mvc.ViewPage<ClassifyViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <ul class="setpBySetp" id="classifyExport">
            <li class="f"></li>
            <li><a href="#import">导 入</a></li>
            <li><a href="#export">导 出</a></li>
        </ul>
        <div id="import">
            <form action="<%=Url.Action("ClassifyImport")%>" method="post" id="importForm" enctype="multipart/form-data">
            <table class="gv">
                <tr>
                    <td colspan="2" class="title">
                        导入选项
                    </td>
                </tr>
                <tr>
                    <td class="width100">
                        导入文件
                    </td>
                    <td>
                        <input type="file" name="importFile" value="" />
                        <%=Html.ActionLink("下载分类导入的模板文件", "ClassifyTemplate") %>
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                    <td>
                        <input type="submit" value="导入" />
                        <%=Html.UrlButton("返回", Url.Action("ClassifyList", new { classifyParams = Model.ClassifyParams.ToString() }))%>
                    </td>
                </tr>
                <tr>
                    <td>
                        注意事项
                    </td>
                    <td>
                        <ul>
                            <li>1. 上传的文件必须是与下载的文件模板一致的文件。</li>
                            <li>2. 已经存在的分类名称，分类特性，分类特性值忽略。</li>
                            <li>3. 发生错误的数据会列表显示。</li>
                        </ul>
                    </td>
                </tr>
            </table>
            </form>
        </div>
        <div id="export">
            <form action="<%=Url.Action("ClassifyExport")%>" method="post" id="exportForm">
            <table class="gv">
                <tr>
                    <td colspan="2" class="title">
                        导出选项
                    </td>
                </tr>
                <tr>
                    <td class="width100">
                        导出分类
                    </td>
                    <td>
                        <%=Html.DropDownList("selClassify", ClassifyHelper.GetClassifyList(Model.ClassifyList, string.Empty)) %>
                    </td>
                </tr>
                <tr>
                    <td>
                        导出内容
                    </td>
                    <td>
                        <input type="checkbox" checked="checked" id="cbClassify" name="cbExportType" value="0" /><label
                            for="cbClassify">分类</label>
                        <input type="checkbox" checked="checked" id="cbProperty" name="cbExportType" value="1" /><label
                            for="cbProperty">分类特性</label>
                        <input type="checkbox" checked="checked" id="cbPropertyVal" name="cbExportType" value="2" /><label
                            for="cbPropertyVal">分类特性值</label>
                    </td>
                </tr>
                <tr>
                    <td>
                        导出文件名称
                    </td>
                    <td>
                        <input type="text" name="tbName" value="ClassifyExport.xls" />
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                    <td>
                        <input type="submit" value="导出" />
                        <%=Html.UrlButton("返回", Url.Action("ClassifyList", new { classifyParams = Model.ClassifyParams.ToString() }))%>
                    </td>
                </tr>
            </table>
            </form>
        </div>
        <ul id="ulerror">
        </ul>
    </div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CssLink" runat="server">
    <link href="<%=Url.Content("~/Css/Common/jquery.tabs.css") %>" rel="stylesheet"
        type="text/css" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="JsLink" runat="server">
    <script src="<%=Url.Content("~/Scripts/Common/ui.core.js") %>" type="text/javascript"></script>
    <script src="<%=Url.Content("~/Scripts/Common/ui.tabs.js") %>" type="text/javascript"></script>
    <script src="<%=Url.Content("~/Scripts/Common/jquery.form.js") %>" type="text/javascript"></script>
    <script src="<%=Url.Content("~/Scripts/Common/jquery.history.js") %>" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="cssContent" runat="server">
    <style type="text/css">
        #ulerror
        {
            margin-top: 10px;
            list-style-type: disc;
        }
        #ulerror li
        {
            padding: 5px 0px;
            border-bottom: solid 1px #f2f2f2;
        }
    </style>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="jsContent" runat="server">
    <script type="text/javascript">
        $(function () {
            var iform = $("#importForm"), eform = $("#exportForm"), ulerr = $("#ulerror");
            var ied = function (bool) { $("#import :submit").attr("disabled", bool) };
            var eed = function (bool) { $("#export :submit").attr("disabled", bool) };
            var showError = function (err) {
                $(err).each(function () { ulerr.append("<li>" + this + "</li>"); });
            };
            var showErrorI = function (o) { ied(false); ulerr.append(o); };
            var showErrorE = function (o) {
                eed(false); showError(o["Error"]);
                if (o["Msg"] == "sucess") {
                    var dUrl = '<%=Url.Action("DownLoadFile") %>';
                    var a = $('<a href="' + dUrl + '" target="_blank">下载文件</a>');
                    var p = $(":text[name='tbName']").parent();
                    p.append(a.click(function () { $(this).remove(); ulerr.empty(); }));
                }
            };
            iform.ajaxForm({ success: showErrorI }).submit(function () { ied(true); ulerr.empty(); });
            eform.ajaxForm({ dataType: "json", success: showErrorE }).submit(function () {
                eed(true); $(":text[name='tbName']").parent().find("a").remove(); ulerr.empty();
            });
            $("#classifyExport").tabs({ select: function (e, ui) { ulerr.empty(); $.history.load(ui.index); } });
            $.history.init(function (i) { $("#classifyExport").tabs("select", parseInt(i == "" ? "0" : i)); });
        });
    </script>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="TopContent" runat="server">
</asp:Content>
